package com.stone.persistent.recyclerview.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.rishabhharit.roundedimageview.RoundedImageView;
import com.stone.persistent.recyclerview.R;

import org.jetbrains.annotations.NotNull;


public class CarouselAdapter extends RecyclerView.Adapter {
    private LayoutInflater inflater;

    @NotNull
    public CarouselViewHolder onCreateViewHolder(@NotNull ViewGroup parent, int viewType) {
        View itemView = this.inflater.inflate(R.layout.item_carousel, parent, false);
        return new CarouselViewHolder(itemView);
    }

    @Override
    public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) {
        int imgRes = position % 5 == 0 ? R.mipmap.carousel_1 :
                (position % 5 == 1 ? R.mipmap.carousel_2 : (position % 5 == 2 ? R.mipmap.carousel_3 : (position % 5 == 3 ? R.mipmap.carousel_4 : R.mipmap.carousel_5)));
        View var10000 = holder.itemView;
        ((RoundedImageView)var10000.findViewById(R.id.carousel_img)).setImageResource(imgRes);
    }


    public int getItemCount() {
        return Integer.MAX_VALUE;
    }

    public CarouselAdapter(Context context) {
        LayoutInflater layoutInflater = LayoutInflater.from(context);
        this.inflater = layoutInflater;
    }


    public  class CarouselViewHolder extends RecyclerView.ViewHolder {

        public CarouselViewHolder(View itemView) {
            super(itemView);
        }
    }
}
